Casey Bralla The NerdWorld Report

J. R. Casey Bralla
377 Farmview Drive
East Earl, PA 17519
610-810-7716

Casey's eMail Address
Technology, Religion, Politics
and
The Mind-Body Dualism Problem

JRC-65 Computer

  1. Introduction and Design Objectives
  2. Clock Circuit

Tech Info


NerdWorld Computer Museum


Essays




Site Hosted by
Vorlon Information Technologies


NerdWorld Logo

Entire site Copyright © 2024 by J. R. Casey Bralla
(except for obvious external works).
All rights reserved.

NOTE: If you link to this site, or otherwise find it useful, please send a brief note to the author.

Casey's eMail Address

Thank you!

JRC-65

A Homebrew 6502 Blinkin' Lights Computer

May 5, 2024


Part 1 - Clock Circuit

One of the prime objectives of this design is the ability to really see what is happening on a CPU level. This means I want to be able to see when the CPU fetches data. I also want to see where the data comes from (which address and which chip), as well as the actual retrieved data itself. At normal CPU speeds (even for the venerable 6502), this happens way too fast for the human eye to see. I therefore want to be able to slow the system clock down enough to make these processes clearly visible. But a clock so slow would make the system unusable, so the clock has to be variable and able to run at "normal" speeds also so that it has at least some functionality. [OK, this system will never be "practical", but it's gotta run like a 1980's computer would run.]

Ben Eater's 6502 kit offers a separate variable-speed clock module using a 555 timer and a potentiometer to control the speed.

Ben's concept is simple and effective in that it allows the CPU to run very slowly or at full speed with just a twist of a dial. He also added the ability to stop/start and single-step the CPU clock. In addition to slow speeds, these functions are also critical to being able to watch the internal workings of the computer.

But I wanted a few more bells and whistles. Firstly, I wanted to be able to instantly and precisely set the CPU clock to a known frequency. (No infinitely-variable twisty knobs for me.) Secondly, I wanted to always know exactly how fast the clock was running. I needed some type of read-out of the current speed.

The solution I decided upon was to use an Arduino as the clock generator. I originally planned to use the Arduino's on-board timers to directly generate the clock signal. But this idea proved to be impractical. For one thing, the Arduino's clock rate of 16 MHz meant that it would have a hard time flipping an output bit at up to 14 MHz. (It would need an internal clock of at least 28 MHz to do this, and then would need a few MHz just to allow for the Arduino to keep up with it's internal systems.) So I elected to use an AD9833 signal generator. These interface well with Arduinos and can generate anything from 0.1 Hz up to 25 MHz. This lets us go dead-slow, but also leaves some headroom above the 6502's max rated speed of 14 MHz. (Maybe I will be able to overclock this beast!) The AD9833 required 3 I/O pins from the Arduino.

To display the current frequency, I chose a standard 16-character x 2-line LCD module. These also easily integrate with the Arduino, taking 6 Arduino I/O pins. I wrote a simple Arduino sketch to display the current clock speed whenever it is changed.

I will use 8 Arduino I/O bits for momentary-contact push buttons to change the speed. I want buttons for:

I was going to have all these buttons call an interrupt routine whenever they were pressed, but I ran up against a limitation in the Arduino Nano's I/O pins. Only a few of the Input pins can trigger an interrupt. No problem though; I simply wrote a sketch that polled the switches in the main loop(). (This also made debouncing the switches easier.)

I also wanted some type of "heartbeat" indicator from the Nano. I wanted this for 3 reasons:

  1. It would show that the Arduino Nano was functioning properly
  2. It can provide a regular signal to the computer for a Real Time Clock (RTC) time base
  3. It's another blinkin' light!
I've programmed the onboard LED connected to D13 on the Arduino to flash in a psuedo heartbeat style with an overall period of 1 second. My plan is that the heartbeat output on D13 will also be tied to the PB6 input pin of the 6522 VIA VIA. This can count the number of pulses, which will enable the computer to keep track of elapsed seconds. (This is especially important because the computer's clock may drastically change speeds so an internal clock reference tied to the master system clock won't be accurate.)

The circuit diagram for the clock is shown here.

The Arduino sketch can be downloaded here.

Click here to download a high definition copy of the video at the top of the page.


Read Part 0 of this series for general information and design objectives.

Stay Tuned for Part 3 of this series, where I breadboard the basic CPU setup and watch the LEDs blink a bit.